﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NutWinFrm
{
    public partial class FileInfoFrm : Form
    {
        public FileInfoFrm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           if(openFileDialog1.ShowDialog().Equals(DialogResult.OK))
            {
                textBox1.Text = openFileDialog1.FileName;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog().Equals(DialogResult.OK))
            {
                textBox2.Text = folderBrowserDialog1.SelectedPath;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            FileStream fs = new FileStream(textBox1.Text, FileMode.Open);
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] rsVal = md5.ComputeHash(fs);
            
            fs.Close();
            StringBuilder sb = new StringBuilder();
            foreach(byte b in rsVal)
            {
                sb.Append(b.ToString("x2"));
            }
            richTextBox1.AppendText("\n\t" + textBox1.Text);
            richTextBox1.AppendText("\n" + sb.ToString());
        }
    }
}
